<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>文章列表</title>
  <!-- 导入CSS -->
  <link rel="stylesheet" href="../../lib/layui/css/layui.css">
  <link rel="stylesheet" href="../../css/article/article-list.css">
</head>

<body>
  <!-- layui卡片面板 -->
  <div class="layui-card">
    <div class="layui-card-header">文章列表</div>
    <div class="layui-card-body">
      <!-- 搜索表单 -->
      <div class="search-form">
        <!-- 行内表单 layui-form-pane方框风格-->
        <form class="layui-form layui-form-pane" lay-filter="search-form">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">分类</label>
              <div class="layui-input-block">
                <select name="cate_id">
                  <option value="">所有分类</option>
                </select>
              </div>
            </div>

            <div class="layui-inline">
              <label class="layui-form-label">状态</label>
              <div class="layui-input-block">
                <select name="state">
                  <option value="">所有状态</option>
                  <option value="0">草稿</option>
                  <option value="1">已发布</option>
                </select>
              </div>
            </div>

            <div class="layui-inline">
              <button class="layui-btn" lay-submit>搜素</button>
              <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
          </div>
        </form>
      </div>
      <!-- 数据表格 -->
      <div class="data-table">
        <table class="layui-table">
          <colgroup>
            <col width="700" />
            <col />
            <col />
            <col />
            <col />
          </colgroup>
          <thead>
            <tr>
              <th>文章标题</th>
              <th>分类</th>
              <th>发表时间</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody></tbody>
        </table>
      </div>
      <!-- 分页器 -->
      <div class="pager" id="pager"></div>
    </div>
  </div>

  <!-- 表格结构模板 -->
  <script type="text/html" id="list-tmp">
    {{each list item}}
      <tr>
        <td><span class="preview-link" data-id="{{item._id}}">{{item.title}}</span></td>
        <td>{{item.cate_name}}</td>
        <td>{{item.create_time}}</td>
        <td>{{item.state ? '已发布' : '草稿'}}</td>
        <td>
          <button class="layui-btn layui-btn-danger layui-btn-sm">删除</button>
        </td>
      </tr>
    {{/each}}
  </script>

  <!-- 文章预览模板 -->
  <script type="text/html" id="preview-tmp">
    <div class="box">
      <!-- 标题 -->
      <h2 class="title">{{data.title}}</h2>
      <!-- 信息 -->
      <div class="info">
        作者：{{data.authorName}} 发布时间：{{data.create_time}} 所属分类：{{data.cate_name}} 状态：{{data.state ? '已发布' : '草稿'}}
      </div>
      <!-- 封面 -->
      <div class="cover"><img src="{{data.cover}}" alt=""></div> 
      <!-- 内容 原文输出-html -->
      <div class="content">{{@ data.content}}</div>
    </div>
  </script>

  <!-- 文章分类模板 -->
  <script type="text/html" id="cate-tmp">
    {{each data item}}
      <option value="{{item._id}}">{{item.name}}</option>
    {{/each}}
  </script>


  <!-- 导入JS -->
  <script src="../../lib/layui/layui.all.js"></script>
  <script src="../../lib/jquery.js"></script>
  <script src="../../lib/template-web.js"></script>
  <script src="../..//js/BASE_API.js"></script>
  <script src="../../js/article/article-list.js"></script>
</body>

</html>